<template>
  <div class="bussInfo">
    <div v-show="!showRentTable">
      <div class="titleTop">
        <el-breadcrumb class="titleText" separator-class="el-icon-arrow-right">
          <el-breadcrumb-item><i class="el-icon-s-home"></i>首页</el-breadcrumb-item>
          <el-breadcrumb-item class="lastTitle">报价试算</el-breadcrumb-item>
        </el-breadcrumb>
        <div class="topBox">
          <span style="font-weight: bold;font-size: 14px;"><i class="el-icon-d-arrow-right"></i>报价试算</span>
        </div>
      </div>
      <el-card class="trialPanel">
        <el-row>
          <el-col :span="12">
            <span class="left-label"><i class="red">*</i>报价方案：</span>
            <div class="right-content">
              <el-select v-model="formData.priceSchemeId" popper-class="priceSelect" @change="handlePriceSchemeChange"
                         filterable placeholder="请选择" style="width: 100%;">
                <el-option v-for="item in priceSchemeList" :label="item.templateName" :value="item.id">
                  <span>{{ item.templateName }}</span>
                  <span style="margin-left: 20px;color: #bbb9b9;">{{ getPriceSchemeSubInfo(item) }}</span>
                </el-option>
              </el-select>
            </div>
          </el-col>
          <el-col :span="12" v-show="priceSchemeSelected.discountFlag == '1'">
            <span class="left-label"><i class="red">*</i>品牌型号：</span>
            <div class="right-content">
              <el-cascader v-model="formData.deviceType" filterable @change="handleBrandDiscountChange" :options="deviceOptions"
                           placeholder="请选择" style="width: 100%">
              </el-cascader>
            </div>
          </el-col>
          <el-col :span="12">
            <span class="left-label"><i class="red">*</i>购置总价：</span>
            <div class="right-content">
              <el-input-number :min="0.00" :precision="2" :step="1" @blur="blurNumber" v-model="formData.purchaseAmt"
                               @change="handleMoneyChange(1)" placeholder="请输入" style="width: 100%"/>
            </div>
          </el-col>
          <el-col :span="12">
            <span class="left-label">首付比例：</span>
            <div class="right-content">
              <el-select v-model="formData.firstPayRate" @change="handleMoneyChange(2)" clearable placeholder="请选择"
                         style="width: 100%">
                <el-option label="10%" value="0.1"/>
                <el-option label="20%" value="0.2"/>
                <el-option label="30%" value="0.3"/>
                <el-option label="40%" value="0.4"/>
                <el-option label="50%" value="0.5"/>
                <el-option label="60%" value="0.6"/>
                <el-option label="70%" value="0.7"/>
                <el-option label="80%" value="0.8"/>
              </el-select>
            </div>
          </el-col>
          <el-col :span="12">
            <span class="left-label"><i class="red">*</i>首付金额：</span>
            <div class="right-content">
              <el-input-number :min="0.00" :precision="2" :step="1" @blur="blurNumber" v-model="formData.firstPayAmt"
                               @change="handleMoneyChange(3)" placeholder="请输入" style="width: 100%"/>
            </div>
          </el-col>
          <el-col :span="12">
            <span class="left-label"><i class="red">*</i>融资金额：</span>
            <div class="right-content">
              <el-input-number v-model="formData.financeAmt" placeholder="请输入"
                               :disabled="true" style="width: 100%"/>
            </div>
          </el-col>
          <el-col :span="12">
            <span class="left-label"><i class="red">*</i>计划起租日：</span>
            <div class="right-content">
              <el-date-picker
                  v-model="formData.startDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  style="width: 100%"
                  :editable="false"
                  :clearable="false"
                  placeholder="请选择">
              </el-date-picker>
            </div>
          </el-col>
          <el-col :span="12">
            <span class="left-label"><i class="red">*</i>租赁期限：</span>
            <div class="right-content">
              <el-select v-model="formData.limitMonth" filterable @change="handleLeaseTerm" placeholder="请选择" style="width: 100%">
                <el-option v-for="m in 36" :label="m+'个月'" :value="m"/>
              </el-select>
            </div>
          </el-col>
          <el-col :span="12">
            <span class="left-label"><i class="red">*</i>还款频率：</span>
            <div class="right-content">
              <el-select v-model="formData.repayRate" placeholder="请选择" style="width: 100%">
                <el-option label="月" value="M"/>
                <el-option label="季度" value="S"/>
              </el-select>
            </div>
          </el-col>
          <el-col :span="12" v-show="showState.leaseRate">
            <span class="left-label"><i class="red">*</i>租赁利率：</span>
            <div class="right-content">
              <el-input-number :min="0.00" :max="100" :precision="2" :step="0.1"
                               v-model="formData.leaseRate" placeholder="请输入" style="width: 100%"/>
            </div>
          </el-col>
          <el-col :span="12">
            <span class="left-label"><i class="red">*</i>租金支付方式：</span>
            <div class="right-content">
              <el-select v-model="formData.payWay" placeholder="请选择" style="width: 100%">
                <el-option label="约定本金" value="YDBJ"/>
                <el-option label="等额本金" value="DEBJ"/>
              </el-select>
            </div>
          </el-col>
          <el-col :span="12" v-show="formData.payWay == 'YDBJ'">
            <span class="left-label">小额还本金额：</span>
            <div class="right-content">
              <el-input-number :min="0.00" :precision="2" :step="1" @blur="blurNumber" v-model="formData.smallAmount"
                               placeholder="请输入" style="width: 100%"/>
            </div>
          </el-col>
          <el-col :span="12" v-show="formData.payWay == 'YDBJ'">
            <span class="left-label">大额还本时间：</span>
            <div class="right-content">
              <el-select v-model="formData.bigAmtMonthArr" multiple :multiple-limit="3" placeholder="请选择"
                         style="width: 100%">
                <el-option v-for="item in bigPayMonthList" :label="item.label" :value="item.value"/>
              </el-select>
            </div>
          </el-col>
          <el-col :span="12" v-show="showState.freePeriod">
            <span class="left-label">免息期：</span>
            <div class="right-content">
              <el-select v-model="formData.freePeriod" placeholder="请选择" style="width: 100%">
                <el-option v-for="item in freePeriodList" :label="item.label" :value="item.value"/>
              </el-select>
            </div>
          </el-col>
          <el-col :span="12" v-show="role == '0' && showState.rebateFirmAmt">
            <span class="left-label">贴息金额：</span>
            <div class="right-content">
              <el-input-number :min="0.00" :precision="2" :step="1" @blur="blurNumber" v-model="formData.rebateFirmAmt"
                               placeholder="请输入" style="width: 100%"/>
            </div>
          </el-col>
          <el-col :span="12" v-show="role == '0' && showState.firmRebateIntrestDate">
            <span class="left-label">贴息时间：</span>
            <div class="right-content">
              <el-select v-model="formData.firmRebateIntrestDate" placeholder="请选择" style="width: 100%">
                <el-option label="起租前" value="before45"/>
                <el-option label="起租后45天" value="after45"/>
              </el-select>
            </div>
          </el-col>
          <el-col :span="12" v-show="showState.lesseeRiskRate">
            <span class="left-label">风险金比例：</span>
            <div class="right-content">
              <el-select v-model="formData.lesseeRiskRate" placeholder="请选择" style="width: 100%">
                <el-option label="0%" value="0"/>
                <el-option label="5%" value="5"/>
              </el-select>
            </div>
          </el-col>
          <el-col :span="12" v-show="showState.otherExpense">
            <span class="left-label">是否赠送保险：</span>
            <div class="right-content">
              <el-select v-model="formData.otherExpense" placeholder="请选择" style="width: 100%">
                <el-option label="是" value="Y"/>
                <el-option label="否" value="N"/>
              </el-select>
            </div>
          </el-col>
          <el-col :span="12" v-show="role == '0' && showState.needXirr">
            <span class="left-label">内部收益率：</span>
            <div class="right-content">
              <el-input-number :min="0.00" :max="100" :precision="2" :step="0.1" @blur="blurNumber"
                               v-model="formData.needXirr" placeholder="请输入" style="width: 100%"/>
            </div>
          </el-col>
        </el-row>
      </el-card>
      <div style="text-align: center;margin: 20px">
        <el-button style="margin-right: 60px" @click="resetData">重置</el-button>
        <el-button type="warning" @click="handleNext">下一步</el-button>
      </div>
    </div>
    <div v-if="showRentTable">
      <div class="titleTop">
        <el-breadcrumb class="titleText" separator-class="el-icon-arrow-right">
          <el-breadcrumb-item><i class="el-icon-s-home"></i>首页</el-breadcrumb-item>
          <el-breadcrumb-item class="lastTitle">报价试算</el-breadcrumb-item>
        </el-breadcrumb>
      </div>
      <rent-plan-table :params="formData" @back="showRentTable = false"></rent-plan-table>
    </div>
  </div>
</template>

<script>
import {getStore} from "@/utils/utils";
import rentPlanTable from "./rentPlanTable";

export default {
  components: {
    rentPlanTable
  },
  data() {
    return {
      role: getStore('role') || '0',
      departId: getStore('departId') || '',
      showRentTable: false,
      formData: {
        //购置总价
        purchaseAmt: '',
        //首付比例
        firstPayRate: '',
          //首付金额
        firstPayAmt: '',
        //融资金额
        financeAmt: '',
        //起租日
        startDate: '',
        //截止日
        endDate: '',
        //租赁期限
        limitMonth: '',
        //租赁期限
        leaseTerm: '0',
        //租赁利率
        leaseRate: undefined,
        //租金支付方式
        payWay: '',
        //还款频率
        repayRate: '',
        //约定小额金额
        smallAmount: '',
        //约定大额月份
        bigAmtMonthArr: [],
        bigAmtMonth: '',
        //设备型号
        deviceType: '',
        //厂商贴息
        rebateFirmAmt: '',
        //厂商贴息时间
        firmRebateIntrestDate: '',
        //承租人风险金比例
        lesseeRiskRate: '',
        //承租人风险金
        lesseeRiskAmt: '',
        //承租人风险金时间
        lesseeRiskDate: '',
        //留购价
        depositAmt: '1',
        //厂商返利
        rebateAmt: '0',
        //其他风险金
        otherRiskAmt: '0',
        //其他风险金时间
        otherRiskDate: '',
        //贴息期内利率
        discountRate: '',
        //贴息期内是否固定小额
        discountSmall: '',
        //贴息时间
        discountTime: '',
        //报价方案名称
        priceSchemeType: '常规报价',
        //报价方案类型
        priceSchemeId: '0',
        //预期收益率
        needXirr: '',
        //免息期限
        freePeriod: '',
        //保险费用
        otherExpense: '',
        //保险费用时间
        otherExpenseDate: 'before45',
        //锁定利率
        leaseRateLock: false,
      },
      showState: {
        leaseRate: true,
        freePeriod: true,
        rebateFirmAmt: true,
        firmRebateIntrestDate: true,
        lesseeRiskRate: true,
        otherExpense: true,
        needXirr: false,
      },
      deviceOptions: [],
      brandTypeMap: {},
      priceSchemeList: [{id: '0', templateName: '常规报价'}],
      freePeriodList: [],
      bigPayMonthList: [],
      priceSchemeSelected: {},
    }
  },
  created() {
    this.initData();
  },
  watch: {
    'formData.startDate': function () {
      this.handleBigPayMonth();
      this.handleLeaseTerm();
    },
    'formData.repayRate': function () {
      this.handleFreePeriod();
      this.handleBigPayMonth();
    },
    'formData.payWay': function () {
      this.handleBigPayMonth();
    },
  },
  methods: {
    initData() {
      this.resetData();
      this.getPriceSchemeData();
      this.getBrandListData();
    },
    getPriceSchemeData() {
      this.$post('/priceSchemeTemplate/configList', {}).then(res => {
        if (res.data && res.data.code == '2000000') {
          const list = [{id: '0', templateName: '常规报价'}];
          res.data.data.forEach(item => list.push(item));
          this.priceSchemeList = list;
        }
      });
    },
    getBrandListData() {
      this.$post('/priceSchemeTemplate/brandList', {}).then(res => {
        if (res.data && res.data.code == '2000000') {
          this.brandTypeMap = res.data.data;
          const options = [];
          this.$xeUtils.objectEach(res.data.data, (item, key) => {
            const children = [];
            this.$xeUtils.objectEach(item, (discount, type) => {
              children.push({label: type, value: type});
            });
            options.push({label: key, value: key, children});
          });
          this.deviceOptions = options;
        }
      });
    },
    getPriceSchemeSubInfo(priceScheme) {
      if (priceScheme.id == '0') {
        return '';
      }
      let info = '';
      if (priceScheme.schemeType) {
        info = info + priceScheme.schemeType;
      }
      if (priceScheme.schemeType != '反推利率' && (priceScheme.leaseRate || priceScheme.leaseRate == '0')) {
        info = info + '、利率' + priceScheme.leaseRate + '%';
      }
      if (priceScheme.extraParam) {
        try {
          const jsonObj = JSON.parse(priceScheme.extraParam);
          if (jsonObj.discountRate) {
            info = info + '、贴息期内利率' + jsonObj.discountRate + '%';
          }
          if (jsonObj.smallAmount == '1') {
            info = info + '、贴息期内固定小额本金';
          }
          if (jsonObj.discountTime) {
            info = info + '、贴息时间' + (jsonObj.discountTime == 'after45' ? '起租后' : '起租前');
          }
        } catch (e) {

        }
      }
      if (priceScheme.discountFlag == '1') {
        info = info + '、享受贴息';
      } else if (priceScheme.discountFlag == '0') {
        info = info + '、不享受贴息';
      }
      if (priceScheme.freeMonth || priceScheme.freeMonth == '0') {
        info = info + '、' + priceScheme.freeMonth + '个月免息期';
      }
      if (priceScheme.riskRate || priceScheme.riskRate == '0') {
        info = info + '、风险金' + priceScheme.riskRate + '%';
      }
      if (priceScheme.payInsurance == '1') {
        info = info + '、赠送保险';
      } else if (priceScheme.payInsurance == '0') {
        info = info + '、不赠送保险';
      }
      if (this.role == '0' && priceScheme.earningRate) {
        info = info + '、收益率' + priceScheme.earningRate + '%';
      }
      return info;
    },
    handleMoneyChange(flag) {
      if (flag != 3 && this.formData.purchaseAmt) {
        if (this.formData.firstPayRate) {
          this.formData.firstPayAmt = this.$xeUtils.round(this.formData.purchaseAmt * this.formData.firstPayRate, 2);
        }
        this.formData.financeAmt = this.formData.purchaseAmt - this.formData.firstPayAmt;
      }
      if (flag == 3 && this.formData.purchaseAmt) {
        this.formData.financeAmt = this.formData.purchaseAmt - this.formData.firstPayAmt;
      }
    },
    repayRateChange() {
      this.handleFreePeriod();
      this.handleBigPayMonth();
    },
    handleFreePeriod() {
      if (!this.showState.freePeriod) {
        return;
      }
      if (this.formData.repayRate == 'M') {
        this.freePeriodList = [{label: '0期', value: '0'}, {label: '3期', value: '3'}, {
          label: '6期',
          value: '6'
        }, {label: '9期', value: '9'}, {label: '12期', value: '12'}];
      } else {
        this.freePeriodList = [{label: '0期', value: '0'}, {label: '1期', value: '1'}, {
          label: '2期',
          value: '2'
        }, {label: '3期', value: '3'}, {label: '4期', value: '4'}];
      }
      this.formData.freePeriod = '0';
    },
    handleBigPayMonth() {
      if (this.formData.payWay == 'DEBJ') {
        this.formData.bigAmtMonthArr = [];
        this.formData.smallAmount = '0.00';
        return;
      }
      if (this.formData.repayRate == 'M') {
        const list = [];
        for (let i = 1; i < 13; i++) {
          list.push({label: i + '月', value: i + '月'})
        }
        this.bigPayMonthList = list;
      } else if (this.formData.startDate) {
        const list = [];
        const startMonth = this.$xeUtils.toDateString(this.formData.startDate, 'M') % 3;
        for (let i = 0; i < 4; i++) {
          const month = startMonth == 0 ? startMonth + 3 * (i + 1) : startMonth + 3 * i;
          list.push({label: month + '月', value: month + '月'});
        }
        this.bigPayMonthList = list;
      }
      this.formData.bigAmtMonthArr = this.formData.startDate ? [this.$xeUtils.toDateString(this.formData.startDate, 'M') + '月'] : [];
    },
    getMonthSpace(date1, date2) {
      if (!date1 || !date2) {
        return 0;
      }
      let year1 = this.$xeUtils.toDateString(date1, 'yyyy') * 1;
      let year2 = this.$xeUtils.toDateString(date2, 'yyyy') * 1;
      let month1 = this.$xeUtils.toDateString(date1, 'M') * 1;
      let month2 = this.$xeUtils.toDateString(date2, 'M') * 1;
      let day1 = this.$xeUtils.toDateString(date1, 'd') * 1;
      let day2 = this.$xeUtils.toDateString(date2, 'd') * 1;
      let yearInterval = year1 - year2;
      if (month1 < month2 || (month1 == month2 && day1 <= day2)) {
        yearInterval = yearInterval - 1;
      }
      let monthInterval = (month1 + 12) - month2;
      if (day1 > day2) {
        monthInterval = monthInterval + 1;
      }
      if (monthInterval % 12 == 0) {
        monthInterval = 12;
      } else {
        monthInterval = monthInterval % 12;
      }
      return yearInterval * 12 + monthInterval;
    },
    handleLeaseTerm() {
      if (this.formData.startDate && this.formData.limitMonth) {
        this.formData.endDate = this.$xeUtils.toDateString(this.$xeUtils.getWhatMonth(this.formData.startDate, this.formData.limitMonth, 10), 'yyyy-MM-dd');
        const diff = this.getMonthSpace(this.formData.endDate, this.formData.startDate);
        this.formData.leaseTerm = diff;
      } else {
        this.formData.leaseTerm = '0';
      }
    },
    blurNumber(e) {
      if (!e.target.value) {
        e.target.value = '0.00';
      }
    },
    handlePriceSchemeChange() {
      if (this.formData.priceSchemeId == '0') {
        this.priceSchemeSelected = {};
        this.formData.priceSchemeType = '常规报价';
        this.formData.deviceType = '';
        this.formData.leaseRate = '';
        this.showState.leaseRate = true;
        this.formData.freePeriod = '0';
        this.showState.freePeriod = true;
        this.formData.lesseeRiskRate = '0';
        this.showState.lesseeRiskRate = true;
        this.formData.otherExpense = 'N';
        this.showState.otherExpense = true;
        this.formData.rebateFirmAmt = '0';
        this.showState.rebateFirmAmt = true;
        this.formData.firmRebateIntrestDate = 'after45';
        this.showState.firmRebateIntrestDate = true;
        this.formData.needXirr = '';
        this.showState.needXirr = false;
      } else {
        this.priceSchemeSelected = this.$xeUtils.find(this.priceSchemeList, item => item.id == this.formData.priceSchemeId);
        this.formData.priceSchemeType = this.priceSchemeSelected.schemeType;
        this.formData.deviceType = '';
        if (this.priceSchemeSelected.schemeType == '反推利率') {
          this.showState.leaseRate = false;
          this.formData.leaseRate = '';
        } else if (this.priceSchemeSelected.leaseRate || this.priceSchemeSelected.leaseRate == '0') {
          this.showState.leaseRate = false;
          this.formData.leaseRate = this.priceSchemeSelected.leaseRate;
        } else {
          this.showState.leaseRate = true;
          this.formData.leaseRate = '';
        }
        if (this.priceSchemeSelected.freeMonth || this.priceSchemeSelected.freeMonth == '0') {
          this.showState.freePeriod = false;
          this.formData.freePeriod = this.priceSchemeSelected.freeMonth;
        } else {
          this.showState.freePeriod = true;
          this.formData.freePeriod = '';
        }
        if (this.priceSchemeSelected.discountFlag || this.priceSchemeSelected.discountFlag == '0') {
          this.formData.rebateFirmAmt = '0';
          this.showState.rebateFirmAmt = false;
          this.formData.firmRebateIntrestDate = 'after45';
          this.showState.firmRebateIntrestDate = false;
        } else {
          this.formData.rebateFirmAmt = '0';
          this.showState.rebateFirmAmt = this.role == '0';
          this.formData.firmRebateIntrestDate = 'after45';
          this.showState.firmRebateIntrestDate = this.role == '0';
        }
        if (this.priceSchemeSelected.riskRate || this.priceSchemeSelected.riskRate == '0') {
          this.showState.lesseeRiskRate = false;
          this.formData.lesseeRiskRate = this.priceSchemeSelected.riskRate;
        } else {
          this.showState.lesseeRiskRate = true;
          this.formData.lesseeRiskRate = '0';
        }
        if (this.priceSchemeSelected.payInsurance || this.priceSchemeSelected.payInsurance == '0') {
          this.showState.otherExpense = false;
          this.formData.otherExpense = this.priceSchemeSelected.payInsurance == '1' ? 'Y' : 'N';
        } else {
          this.showState.otherExpense = true;
          this.formData.otherExpense = 'N';
        }
        if (this.priceSchemeSelected.schemeType == '反推利率' || this.priceSchemeSelected.schemeType == '反推贴息') {
          this.showState.needXirr = this.role == '0' ? true : false;
          this.formData.needXirr = this.priceSchemeSelected.earningRate || '';
        } else {
          this.showState.needXirr = false;
          this.formData.needXirr = '';
        }
      }
    },
    handleBrandDiscountChange(info) {
      if (info && info.length > 1) {
        const brand = info[0];
        const type = info[1];
        const typeInfo = this.brandTypeMap[brand] || {};
        const discountInfo = typeInfo[type] || {};
        const {discountAmt, discountDate} = discountInfo;
        if (discountAmt || discountAmt == '0') {
          this.formData.rebateFirmAmt = discountAmt;
          this.formData.firmRebateIntrestDate = discountDate == '起租前' ? 'before45' : 'after45';
        }
      }
    },
    resetData() {
      this.formData.purchaseAmt = '0.00';
      this.formData.firstPayRate = '';
      this.formData.firstPayAmt = '0.00';
      this.formData.financeAmt = '0.00';
      this.formData.startDate = this.$xeUtils.toDateString(new Date(), 'yyyy-MM-dd');
      this.formData.limitMonth = 36;
      this.formData.repayRate = 'M';
      this.formData.payWay = 'YDBJ';
      this.formData.smallAmount = '0.00';
      if (this.showState.leaseRate) {
        this.formData.leaseRate = undefined;
      }
      if (this.showState.rebateFirmAmt) {
        this.formData.rebateFirmAmt = '0.00';
      }
      if (this.showState.firmRebateIntrestDate) {
        this.formData.firmRebateIntrestDate = 'after45';
      }
      if (this.showState.freePeriod) {
        this.formData.freePeriod = '0';
      }
      if (this.showState.lesseeRiskRate) {
        this.formData.lesseeRiskRate = '0';
      }
      if (this.showState.otherExpense) {
        this.formData.otherExpense = 'N';
      }
      this.handleFreePeriod();
      this.handleBigPayMonth();
      this.handleLeaseTerm();
    },
    checkData() {
      if (this.priceSchemeSelected.discountFlag == '1' && !this.formData.deviceType) {
        return "请选择品牌型号";
      }
      if (!this.formData.purchaseAmt) {
        return "购置总价需要大于0";
      }
      if (!this.formData.firstPayAmt) {
        return "首付金额需要大于0";
      }
      if (!this.formData.startDate) {
        return "请选择计划起租日";
      }
      if (!this.formData.limitMonth || !this.formData.leaseTerm) {
        return "请选择租赁期限";
      }
      if (this.showState.leaseRate && !this.formData.leaseRate && this.formData.leaseRate != '0') {
        return "请输入租赁利率";
      }
      if (this.$xeUtils.toNumber(this.formData.firstPayAmt) > this.$xeUtils.toNumber(this.formData.purchaseAmt)) {
        return "首付金额不能大于购置总价";
      }
      if (this.$xeUtils.toNumber(this.formData.financeAmt) <= 0) {
        return "融资金额需要大于0";
      }
      if (this.$xeUtils.toNumber(this.formData.financeAmt) > this.$xeUtils.toNumber(this.formData.purchaseAmt)) {
        return "融资金额不能大于购置总价";
      }
      if (this.$xeUtils.divide(this.$xeUtils.toNumber(this.formData.firstPayAmt), this.$xeUtils.toNumber(this.formData.purchaseAmt)) < 0.1) {
        return "首付金额不能低于购置总价的10%";
      }
      if (this.$xeUtils.toNumber(this.formData.smallAmount) > 0 && this.$xeUtils.toNumber(this.formData.smallAmount) * this.formData.limitMonth > this.$xeUtils.toNumber(this.formData.financeAmt)) {
        return '小额还本累加金额不能大于融资金额';
      }
      if (this.role == '0' && this.showState.needXirr && !this.formData.needXirr && this.formData.needXirr != '0') {
        return "请输入内部收益率";
      }
    },
    handleNext() {
      const message = this.checkData();
      if (message) {
        this.$message.warning(message);
        return;
      }
      this.formData.lesseeRiskAmt = this.$xeUtils.toNumber(this.formData.financeAmt) * this.$xeUtils.toNumber(this.formData.lesseeRiskRate) / 100;
      this.formData.bigAmtMonth = this.formData.bigAmtMonthArr && this.formData.bigAmtMonthArr.length > 0 ? this.formData.bigAmtMonthArr.join(",") : '';
      this.formData.lesseeRiskDate = this.formData.startDate;
      this.formData.otherRiskDate = this.formData.startDate;
      if (this.priceSchemeSelected.extraParam) {
        try {
          const jsonObj = JSON.parse(this.priceSchemeSelected.extraParam) || {};
          this.formData.discountRate = jsonObj.discountRate;
          this.formData.discountSmall = jsonObj.smallAmount;
          this.formData.discountTime = jsonObj.discountTime;
        } catch (e) {
          this.formData.discountRate = '';
          this.formData.discountSmall = '';
          this.formData.discountTime = '';
        }
      } else {
        this.formData.discountRate = '';
        this.formData.discountSmall = '';
        this.formData.discountTime = '';
      }
      this.formData.leaseRateLock = !this.showState.leaseRate;
      this.showRentTable = true;
    },
  },
}
</script>

<style lang="less" scoped>
.titleTop {
  width: 100%;

  .titleText {
    font-size: 14px;
    line-height: 50px;

    .lastTitle .el-breadcrumb__inner {
      color: #d76500;
    }
  }

  .topBox {
    height: 35px;
    color: #d76500;
    background: #fff3e9;
    border: 1px solid #ffcb9d;
    line-height: 35px;
    position: relative;
    padding-bottom: 0px;
    margin-top: 5px;

    > span {
      margin-left: 10px;
    }

    label {
      position: absolute;
      top: 10px;
      right: 15px;
      width: 100px;
      height: 30px;
      text-align: center;
      line-height: 30px;
      background: #3385ff;
      border-radius: 5px;
    }
  }
}

.bussInfo {
  padding: 0px 20px;

  .trialPanel {
    .el-row {
      border-top: 1px solid #EBEEF5;
      border-left: 1px solid #EBEEF5;

      .el-col {
        border-bottom: 1px solid #EBEEF5;
        border-right: 1px solid #EBEEF5;
        height: 60px;
        line-height: 40px;
        padding: 10px;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
      }
    }

    .left-label {
      width: 130px;
      float: left;
      text-align: right;
    }

    .right-content {
      position: relative;
      margin-left: 150px;
      margin-right: 30px;
    }
  }

  ::v-deep .el-card {
    border: 0px;
  }

  ::v-deep .el-card__body {
    padding: 0px;
  }

  .red {
    color: red;
    font-size: 18px;
    margin-right: 5px;
  }
}

</style>